const app = getApp()
var http = require("../../../utils/httpUtils.js")
var common = require("../../../utils/common.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    textareaStr: "",
    orderSelectId: 0,
    orderSelectArr: [{
      id: 0,
      name: '预约不上',
      checked: 'true'
    }, {
      id: 1,
      name: '机构不接待团购用户',
    }, {
      id: 2,
      name: '店里活动更优惠',
    }, {
      id: 3,
      name: '网上评价不好',
    }, {
      id: 4,
      name: '计划有变没时间上课',
    }, {
      id: 5,
      name: '联系不上机构',
    }, {
      id: 6,
      name: '机构说可以以团购价直接去店里消费',
    }],
    orderData: []
  },

  submitBtn: function (e) {
    console.log(this.data.orderSelectId)
    console.log(this.data.textareaStr)
    var that = this
    var urls = app.globalData.SERVER_IP + "/order/submit_apply_refund"
    var parasm = {
      "of_refund_cash": this.data.orderData.of_refund_cash,
      "of_refund_reason": this.data.orderSelectArr[this.data.orderSelectId].name,
      "of_dec": this.data.textareaStr || "无",
      "of_oid": this.data.orderData.o_id,
      "of_ono": this.data.orderData.o_no
    }
    console.log(parasm)
    // 下单
    http.P(urls, parasm, (res) => {
      console.log(res)
      if(res.success){
        wx.navigateTo({
          url: '../refund_order/refund_order',
        })
      }else{
        wx.showToast({
          title: res.error.message,
          icon: 'none',
          duration: 2000
        })
      }

    }, (err) => {
      console.log("获取信息失败")
      console.log(err)
    })
  },

  textareaInput: function (e) {
    this.setData({
      textareaStr: e.detail.value
    })
  },

  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    this.setData({
      orderSelectId: e.detail.value
    })
  },

  go_evaluate: function (options) {
    wx.navigateTo({
      url: '../refund_detail/refund_detail',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      orderData: options
    })
    wx.setNavigationBarTitle({
      title: '退款/售后',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    wx.hideShareMenu({})
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

})